// 导入axios实例中的AxiosResponse泛型接口
import { AxiosResponse } from "axios";
//导入封装的axios请求方法
import request from "../requestMethod";
import {LoginReq, PageUniAppUserReqVO, PageUserReqVO} from "@/interface/user.ts";
import {MovieReqVO, PageMovieReqVO} from "@/interface/movie.ts";
import {MovieTypeReqVo, PageMovieTypeReqVO} from "@/interface/movie-type.ts";
import {MovieCinemaReqVO, PageMovieCinemaReqVO} from "@/interface/movie-cinema.ts";
import {MovieOrderReqVO, PageMovieOrderReqVO} from "@/interface/movie-order.ts";
import {MovieSessionReqVO, PageMovieSessionReqVO} from "@/interface/movie-session.ts";
import {AuditReqVO, PageOrderAuditReqVO} from "@/interface/order-audit.ts";
import {CreateChargeReqVO, PageChargeReqVO} from "@/interface/charge.ts";
// 参数类型导入


//  如果是get请求不需要写method，post请求使用data请求体 默认封装的get
// post示例
//  export const login = (data) => request({ method: "post", url: '/login', data: data });

// get示例
//  export const getUserList = (params) => request({ url: '/users', params });

// put示例
//     export const getEdit = (data) => request({
//      method: "put",
//      data,
//      url: "users/" + data.uid + "/state/" + data.type,
//    })

/**
 * 首页数据接口
 * @param data
 */
export const useGetIndexDataApi = ():Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin",
    })
/**
 * 注册接口
 * @param data
 */
export const useRegisterApi = (data:LoginReq):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/user/register",
        data,
    })
/**
 * 登录接口
 * @param data
 */
export const useLoginApi = (data:LoginReq):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/user/login",
        data,
    })

export const usePageUserApi = (data: PageUserReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/user",
        data,
    })

export const useMovieAddApi = (data: MovieReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movie/add",
        data,
    })

export const useMovieEditApi = (data: MovieReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movie/edit",
        data,
    })
export const usePageMovieApi = (data: PageMovieReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movie",
        data,
    })

export const useMovieSelectListApi = ():Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movie/selectList"
    })

export const useMovieTypeAddApi = (data: MovieTypeReqVo):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieType/add",
        data,
    })
export const useMovieTypeEditApi = (data: MovieTypeReqVo):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieType/edit",
        data,
    })
export const usePageMovieTypeApi = (data: PageMovieTypeReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieType",
        data,
    })
export const useMovieTypeSelectListApi = ():Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieType/selectList"
    })
export const useCinemaTypeAddApi = (data: MovieCinemaReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/cinemaType/add",
        data,
    })
export const useCinemaTypeEditApi = (data: MovieCinemaReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/cinemaType/edit",
        data,
    })
export const usePageCinemaTypeApi = (data: PageMovieCinemaReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/cinemaType",
        data,
    })
export const useCinemaSelectListApi = ():Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/cinemaType/selectList"
    })
export const useMovieOrderEditApi = (data: MovieOrderReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieOrder/edit",
        data,
    })
export const usePageMovieOrderApi = (data: PageMovieOrderReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieOrder",
        data,
    })
export const useMovieSessionAddApi = (data: MovieSessionReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieSession/add",
        data,
    })
export const useMovieSessionEditApi = (data: MovieSessionReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieSession/edit",
        data,
    })
export const usePageMovieSessionApi = (data: PageMovieSessionReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/movieSession",
        data,
    })

export const usePageUniAppUserApi = (data: PageUniAppUserReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/uniAppUser",
        data,
    })
export const useAdminUpdateUserInfoApi = (data: PageUniAppUserReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/user/update",
        data,
    })

export const usePageCancelOrderApi = (data: PageOrderAuditReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/cancelOrder",
        data,
    })

export const useAuditApi = (data: AuditReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/cancelOrder/audit",
        data,
    })

export const usePageChargeApi = (data: PageChargeReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/charge",
        data,
    })

export const useCreateChargeApi = (data: CreateChargeReqVO):Promise<AxiosResponse<any, any>> =>
    request({
        method:"POST",
        url:"/admin/charge/create",
        data,
    })




// 如何在组件使用
/*
// post请求
import { login } from "@/api/api";
const { data: res } = await login(loginForm);
if (res.meta.status !== 200) return ELMessage.error("登录失败！");
ELMessage.success("登录成功！");
// 保存token
localStorage.setItem("token", res.data.token);
// 跳转到首页
router.push("/");
// 获取用户信息
getUserInfoList();
// get请求
import { getUserList } from "@/api/api";
const { data: res } = await getUserList({ pageNum: 1, pagesize: 2 });
if (res.meta.status !== 200) return ELMessage.error("获取分类列表失败！");
editCateForm = res.data;
editCateDialogVisible.value = true;
// put请求
import { getEdit } from "@/api/api";
const { data: res } = await getEdit({
  uid: row.uid,
  type: row.mg_state,
});
if (res.meta.status !== 200) return ELMessage.error("修改状态失败！");
ELMessage.success("修改状态成功！");
getUserList();
*/